package stu.day33_day38.day38;

import java.util.Scanner;

public class hw2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] nums = new int[n];

        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }

        int xorsum = 0;
        for (int num : nums) {
            xorsum ^= num;
        }

        if (xorsum == 0) {
            int sum = 0;
            int min = Integer.MAX_VALUE;
            for (int num : nums) {
                sum += num;
                min = Math.min(min, num);
            }
            System.out.println(sum - min);
        } else {
            System.out.println(-1);
        }
    }

}
